package cn.com.dhcc.turbo.core;

import java.util.ArrayList;

import cn.com.dhcc.app.core.util.XstreamUtil;
import cn.com.dhcc.turbo.entity.api.MonitorLog;
import cn.com.dhcc.turbo.entity.api.MonitorLogs;

public class BeanToXml {

	public static void main(String[] args) throws Exception {
		MonitorLogs monitorLogs = new MonitorLogs();
		monitorLogs.setMessage("qiaobing");
		monitorLogs.setStatus("1");
		monitorLogs.setMonitorLogList(new ArrayList<MonitorLog>());
		MonitorLog monitorLog = new MonitorLog();
		monitorLog.setId("1111");
		monitorLogs.getMonitorLogList().add(monitorLog);
		MonitorLog monitorLog2 = new MonitorLog();
		monitorLog2.setId("1111");
		monitorLogs.getMonitorLogList().add(monitorLog2);
		//不用注解去包名，但是再转回对象的时候，需要用注解，否则找不到类
		String xmls = XstreamUtil.toXml(monitorLogs);
		System.out.println(xmls);
		System.out.println(XstreamUtil.toObject(MonitorLogs.class, xmls));
		//不用注解时，xml会有报名，转回来时没问题，
		String xml = XstreamUtil.toShortXml(monitorLogs,new Class<?>[]{MonitorLogs.class,MonitorLog.class});
		System.out.println(xml);
		System.out.println(XstreamUtil.shortXmlToObj(xml, new Class<?>[]{MonitorLogs.class,MonitorLog.class}));
	//	System.out.println(XstreamUtil.toObject(MonitorLogs.class, str));
	}
}
